package com.xxl.controller;

import com.xxl.dto.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.ConstraintViolationException;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import org.hibernate.validator.constraints.Length;
import org.springframework.validation.annotation.Validated;

/**
 * 用户api
 *
 * @author xxl
 * @date 2023/3/19
 */
@Tag(name = "UserApi",description = "用户相关操作接口")
@Validated
public interface UserApi<R> {
    /**
     * 登录
     */
    @Operation(summary = "login方法",description = "登录")
    @ApiResponse(responseCode = "200",description = "登录成功")
    @Parameters(
            {
                    @Parameter(name = "username",description = "用户姓名"),
                    @Parameter(name = "password",description = "用户密码")
            }
    )

    R login(@Min(value = 2,message = "字符长度最小不能小于2") String username, @NotEmpty(message = "不能为空字符串")  String password) ;

    /**
     * 增加用户
     */
    @Operation(summary = "add方法",description = "增加用户")
    @ApiResponse(responseCode = "200",description = "登录成功")
    @Parameter(name = "user",description = "用户实体类")
    R add(User user);

    /**
     * 删除用户
     */
    @Operation(summary = "delete方法",description = "删除用户")
    @ApiResponse(responseCode = "200",description = "删除成功")
    @Parameter(name = "key",description = "删除用户的key,也就是姓名")
    R delete(@NotNull(message = "不能为空") @NotEmpty(message = "不能为字符串") @Length(min = 1,max = 3,message = "字符串长度 i < 1 或者 i >  3,在这两个范围就报错") String key);

    /**
     * 查询用户
     */
    @Operation(summary = "query方法",description = "查询所有用户")
    @ApiResponse(responseCode = "200",description = "查询成功")
    R query();

}
